namespace KinonekoSoftware.CodariaDB.Runtimes.Categories
{
    public sealed class InstanceCatalogRoot : EmbeddedObject
    {
        
        public static void Create(ICollection<InstanceCatalog> collection, InstanceType type)
        {
            var c = new InstanceCatalog
            {
                Id            = ID.GetShortID(),
                UseCustomType = false,
                Name          = LanguageManager.GetEnum(type),
                Type          = type,
                IsVisible     = true,
            };

            collection.Add(c);
        }
        
        public static void Create(ICollection<InstanceCatalog> collection, string name, string type)
        {
            var c = new InstanceCatalog
            {
                Id            = ID.GetShortID(),
                UseCustomType = true,
                Name          = name,
                CustomType    = type,
                IsVisible     = true,
            };

            collection.Add(c);
        }
        
        private static void CreateCatalog(ICollection<InstanceCatalog> collection)
        {
            Create(collection, InstanceType.Character);
            Create(collection, InstanceType.Ability);
            Create(collection, InstanceType.Species);
            Create(collection, InstanceType.Plant);
            Create(collection, InstanceType.Geography);
            Create(collection, InstanceType.PoliticalGroups_Country);

            Create(collection, InstanceType.Team);
            Create(collection, InstanceType.Team_Kizuna);
            Create(collection, InstanceType.Team_Club);
            Create(collection, InstanceType.Team_Group);
            Create(collection, InstanceType.Team_Gangs);
            // Create(collection, InstanceType.Team_Compose);

            Create(collection, InstanceType.Item);
            Create(collection, InstanceType.Item_Item);
            Create(collection, InstanceType.Item_Material);
            Create(collection, InstanceType.Item_Weapon);
            Create(collection, InstanceType.Item_Equipment);
            Create(collection, InstanceType.Item_Resources);

            Create(collection, InstanceType.Others);
            Create(collection, InstanceType.Others_School);
            Create(collection, InstanceType.Others_Class);
            Create(collection, InstanceType.Others_Company);
            Create(collection, InstanceType.Others_Family);


            // 政治集团当前未全部开放。
            // 
            // Create(collection, InstanceType.PoliticalGroups);
            // Create(collection, InstanceType.PoliticalGroups_Force);
            // Create(collection, InstanceType.PoliticalGroups_MilitaryOrg);
            // Create(collection, InstanceType.PoliticalGroups_Tribe);
            // Create(collection, InstanceType.PoliticalGroups_Clans);
            // Create(collection, InstanceType.PoliticalGroups_Religion);
        }

        public static InstanceCatalogRoot Create()
        {
            var root = new InstanceCatalogRoot
            {
                Catalogs = new List<InstanceCatalog>(8)
            };
            
            CreateCatalog(root.Catalogs);

            return root;
        }
        
        public List<InstanceCatalog> Catalogs { get; set; }
    }
}